package com.reflex;

public class ArgDemo {
    public static void main(String[] args) {
        //可变参数的本质是数组
        sum(1);
        sum(1, 2);
        sum(1, 2, 3);
    }

    //可变参数求和
    private static void sum(int... num) {
        int sum = 0;
        for (int i : num) {
            sum += i;
        }
        System.out.println("sum = " + sum);
    }
}
